package h0712;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
/**
  * @description 分配土地
  * @author 不知名帅哥
  * @date 2024/7/12 22:52
  * @version 1.0
*/
public class AllocateLand {
    static class Area {
        int minX;
        int maxX;
        int minY;
        int maxY;

        //每次set算出最大坐标，最小坐标
        public void setX(int x) {
            this.minX = Math.min(x, this.minX);
            this.maxX = Math.max(x, this.maxX);
        }

        public void setY(int y) {
            this.minY = Math.min(y, this.minY);
            this.maxY = Math.max(y, this.maxY);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int w = sc.nextInt();
        sc.nextLine();
        int[][] land = new int[w][l];
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < l; j++) {
                land[i][j] = sc.nextInt();
            }
        }
        int area = getResult(land, l, w);
        System.out.println(area);
    }

    private static int getResult(int[][] land, int l, int w) {
        List<Integer> x = new ArrayList<>();
        List<Integer> y = new ArrayList<>();
        HashMap<Integer, Area> map = new HashMap<>();
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < l; j++) {
                map.putIfAbsent(land[i][j], new Area());
                map.get(land[i][j]).setX(i);
                map.get(land[i][j]).setY(j);
            }
        }
        int max = 0;
        for (Integer key : map.keySet()) {
            Area area = map.get(key);
            max = Math.max(max, (area.maxX - area.minX + 1) * (area.maxY - area.minY + 1));
        }

        return max;
    }

}
